package chart;

import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
import java.util.Date;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.AxisLocation;
import org.jfree.chart.axis.DateAxis;
import org.jfree.data.time.Millisecond;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.chart.labels.CustomXYToolTipGenerator;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.axis.NumberAxis;

import db.DatabaseManager;
import db.entity.PadLife;
import db.entity.PadeLapse;
import db.entity.StationStatus;

import util.Constants;

public class QueryDataChartPanel extends ChartPanel{
	
	private static final long serialVersionUID = 1L;
	
	private boolean temperature = false;
	private boolean vacuumL = false;
	private boolean vacuumR = false;
	private boolean pressureL = false;
	private boolean pressureR = false;
	private boolean padlife = false;
	
	private TimeSeries tempSeries = null;
	private TimeSeries vacuumLSeries = null;
	private TimeSeries vacuumRSeries = null;
	private TimeSeries pressureLSeries = null;
	private TimeSeries pressureRSeries = null;
	private TimeSeries padLifeSeries = null;
	
	private TimeSeriesCollection tempDataset = null;
	private TimeSeriesCollection vacuumLDataset = null;
	private TimeSeriesCollection vacuumRDataset = null;
	private TimeSeriesCollection pressureLDataset = null;
	private TimeSeriesCollection pressureRDataset = null;
	private TimeSeriesCollection padLifeDataset = null;
	
	private NumberAxis temperatureAxis = null;
	private NumberAxis vacuumLAxis = null;
	private NumberAxis vacuumRAxis = null;
	private NumberAxis pressureLAxis = null;
	private NumberAxis pressureRAxis = null;
	private NumberAxis padLifeAxis = null;
	private DateAxis dateAxis = null;
	
	private ArrayList<String> tmpToolTipArray = null;
	private ArrayList<String> vcLToolTipArray = null;
	private ArrayList<String> vcRToolTipArray = null;
	private ArrayList<String> prLToolTipArray = null;
	private ArrayList<String> prRToolTipArray = null;
	private ArrayList<String> padToolTipArray = null;
	
	private XYPlot queryDataPlot = null;
	private JFreeChart queryDataChart = null;
	
	
	/**
	 * Create a ChartPanel which contains Line Chart of Query Data Interface
	 */
	public QueryDataChartPanel()
	{
		super(null);
		initSeries();
		initAxis();
		initToolTipArray();
		renderPlot();
		queryDataChart = new JFreeChart("Polisher", JFreeChart.DEFAULT_TITLE_FONT, queryDataPlot, true);
		this.setChart(queryDataChart);
		this.setDisplayToolTips(true);
	}
	
	/**
	 * Initialise all series and data set of the graph.
	 */
	private void initSeries()
	{
		tempSeries = new TimeSeries("Temperature");		
		tempDataset = new TimeSeriesCollection();
		tempDataset.addSeries(tempSeries);
		
		vacuumLSeries = new TimeSeries("Vacuum L");	
		vacuumLDataset = new TimeSeriesCollection();
		vacuumLDataset.addSeries(vacuumLSeries);

		vacuumRSeries = new TimeSeries("Vacuum R");		
		vacuumRDataset = new TimeSeriesCollection();	
		vacuumRDataset.addSeries(vacuumRSeries);

		pressureLSeries = new TimeSeries("Pressure L");	
		pressureLDataset = new TimeSeriesCollection();		
		pressureLDataset.addSeries(pressureLSeries);

		pressureRSeries = new TimeSeries("Pressure R");	
		pressureRDataset = new TimeSeriesCollection();		
		pressureRDataset.addSeries(pressureRSeries);
		
		padLifeSeries = new TimeSeries("Pad Life");
		padLifeDataset = new TimeSeriesCollection();
		padLifeDataset.addSeries(padLifeSeries);
	}
	
	/**
	 * Initialise all Axis-X and Axis-Y of the graph
	 */
	private void initAxis()
	{
		temperatureAxis = new NumberAxis("Temperature (Celsius)");
		temperatureAxis.setLabelPaint(Color.red);
		temperatureAxis.setNumberFormatOverride(Constants.GRAPH_DF);
		temperatureAxis.setAutoRangeIncludesZero(false);
		
		vacuumLAxis = new NumberAxis("Vacuum L (Inches Hg)");
		vacuumLAxis.setLabelPaint(Color.blue);
		vacuumLAxis.setNumberFormatOverride(Constants.GRAPH_DF);
		vacuumLAxis.setAutoRangeIncludesZero(false);
		
		vacuumRAxis = new NumberAxis("Vacuum R (Inches Hg)");
		vacuumRAxis.setLabelPaint(Constants.ORANGE);
		vacuumRAxis.setNumberFormatOverride(Constants.GRAPH_DF);
		vacuumRAxis.setAutoRangeIncludesZero(false);
		
		pressureLAxis = new NumberAxis("Pressure L (PSI)");
		pressureLAxis.setLabelPaint(Constants.DARK_GREEN);
		pressureLAxis.setNumberFormatOverride(Constants.GRAPH_DF);
		pressureLAxis.setAutoRangeIncludesZero(false);
		
		pressureRAxis = new NumberAxis("Pressure R (PSI)");
		pressureRAxis.setLabelPaint(Color.cyan);
		pressureRAxis.setNumberFormatOverride(Constants.GRAPH_DF);
		pressureRAxis.setAutoRangeIncludesZero(false);
				
		padLifeAxis = new NumberAxis("Pad Life (Hour)");
		padLifeAxis.setLabelPaint(Color.magenta);
		padLifeAxis.setNumberFormatOverride(Constants.GRAPH_DF);
		padLifeAxis.setAutoRangeIncludesZero(false);
		
		dateAxis = new DateAxis();
		dateAxis.setDateFormatOverride(new SimpleDateFormat("dd,MMM,yyyy(hh:mm:ssa)"));
	}
		
	/**
	 * Initialise the Tool Tip Array
	 */
	private void initToolTipArray()
	{
		tmpToolTipArray = new ArrayList<String>();
		vcLToolTipArray = new  ArrayList<String>();
		vcRToolTipArray = new  ArrayList<String>();
		prLToolTipArray = new  ArrayList<String>();
		prRToolTipArray = new  ArrayList<String>();
		padToolTipArray = new  ArrayList<String>();
	}
	
	/**
	 * Render the graph plot, setting the Look and Feel, Tool Tip, Axis, and Data Set
	 */
	private void renderPlot()
	{
		queryDataPlot = new XYPlot();
		
		//Temperature
		XYLineAndShapeRenderer tempRenderer = new XYLineAndShapeRenderer();
		tempRenderer.setBaseShape(new Rectangle2D.Float(-2.0F, -2.0F, 4.0F, 4.0F));
		tempRenderer.setBasePaint(Color.red);
		tempRenderer.setUseFillPaint(true);
		tempRenderer.setBaseFillPaint(Color.LIGHT_GRAY);
		tempRenderer.setBaseShapesVisible(true);
		tempRenderer.setBaseShapesFilled(true);
		tempRenderer.setSeriesPaint(0, Color.red);
		CustomXYToolTipGenerator tmpToolTipGenerator = new CustomXYToolTipGenerator();
		tmpToolTipGenerator.addToolTipSeries(this.tmpToolTipArray);
		// XYToolTipGenerator tempToolTipGenerator = new StandardXYToolTipGenerator("{0}: ({1}, {2})", DateFormat.getDateTimeInstance(), NumberFormat.getInstance());
		tempRenderer.setBaseToolTipGenerator(tmpToolTipGenerator);
				
		queryDataPlot.setRangeAxis(0, temperatureAxis);
		queryDataPlot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT);
		queryDataPlot.setDataset(0, tempDataset);
		queryDataPlot.mapDatasetToRangeAxis(0, 0);
		queryDataPlot.setRenderer(0, tempRenderer);
	
		//Vacuum Left
		XYLineAndShapeRenderer vacLRenderer = new XYLineAndShapeRenderer();
		vacLRenderer.setBaseShape(new Rectangle2D.Float(-2.0F, -2.0F, 4.0F, 4.0F));
		vacLRenderer.setBasePaint(Color.blue);
		vacLRenderer.setUseFillPaint(true);
		vacLRenderer.setBaseFillPaint(Color.LIGHT_GRAY);
		vacLRenderer.setBaseShapesVisible(true);
		vacLRenderer.setBaseShapesFilled(true);
		vacLRenderer.setSeriesPaint(0, Color.blue);
		CustomXYToolTipGenerator vcLToolTipGenerator = new CustomXYToolTipGenerator();
		vcLToolTipGenerator.addToolTipSeries(this.vcLToolTipArray);
		//XYToolTipGenerator vacLToolTipGenerator = new StandardXYToolTipGenerator("{0}: ({1}, {2})", DateFormat.getDateTimeInstance(), NumberFormat.getInstance());
		vacLRenderer.setBaseToolTipGenerator(vcLToolTipGenerator);
					
		queryDataPlot.setRangeAxis(1, vacuumLAxis);
		queryDataPlot.setRangeAxisLocation(1, AxisLocation.TOP_OR_LEFT);
		queryDataPlot.setDataset(1, vacuumLDataset);
		queryDataPlot.mapDatasetToRangeAxis(1, 1);
		queryDataPlot.setRenderer(1, vacLRenderer);
	
		//Vacuum Right
		XYLineAndShapeRenderer vacRRenderer = new XYLineAndShapeRenderer();
		vacRRenderer.setBaseShape(new Rectangle2D.Float(-2.0F, -2.0F, 4.0F, 4.0F));
		vacRRenderer.setBasePaint(Constants.ORANGE);
		vacRRenderer.setUseFillPaint(true);
		vacRRenderer.setBaseFillPaint(Color.LIGHT_GRAY);
		vacRRenderer.setBaseShapesVisible(true);
		vacRRenderer.setBaseShapesFilled(true);
		vacRRenderer.setSeriesPaint(0, Constants.ORANGE);
		CustomXYToolTipGenerator vcRToolTipGenerator = new CustomXYToolTipGenerator();
		vcRToolTipGenerator.addToolTipSeries(this.vcRToolTipArray);
		//XYToolTipGenerator vacRToolTipGenerator = new StandardXYToolTipGenerator("{0}: ({1}, {2})", DateFormat.getDateTimeInstance(), NumberFormat.getInstance());
		vacRRenderer.setBaseToolTipGenerator(vcRToolTipGenerator);
		
		queryDataPlot.setRangeAxis(2, vacuumRAxis);
		queryDataPlot.setRangeAxisLocation(2, AxisLocation.TOP_OR_LEFT);
		queryDataPlot.setDataset(2, vacuumRDataset);
		queryDataPlot.mapDatasetToRangeAxis(2, 2);
		queryDataPlot.setRenderer(2, vacRRenderer);
	
		//Pressure Left
		XYLineAndShapeRenderer prsLRenderer = new XYLineAndShapeRenderer();
		prsLRenderer.setBaseShape(new Rectangle2D.Float(-2.0F, -2.0F, 4.0F, 4.0F));
		prsLRenderer.setBasePaint(Constants.DARK_GREEN);
		prsLRenderer.setUseFillPaint(true);
		prsLRenderer.setBaseFillPaint(Color.LIGHT_GRAY);
		prsLRenderer.setBaseShapesVisible(true);
		prsLRenderer.setBaseShapesFilled(true);
		prsLRenderer.setSeriesPaint(0, Constants.DARK_GREEN);
		CustomXYToolTipGenerator prLToolTipGenerator = new CustomXYToolTipGenerator();
		prLToolTipGenerator.addToolTipSeries(this.prLToolTipArray);
		//XYToolTipGenerator prsLToolTipGenerator = new StandardXYToolTipGenerator("{0}: ({1}, {2})", DateFormat.getDateTimeInstance(), NumberFormat.getInstance());
		prsLRenderer.setBaseToolTipGenerator(prLToolTipGenerator);
		
		queryDataPlot.setRangeAxis(3, pressureLAxis);
		queryDataPlot.setRangeAxisLocation(3, AxisLocation.BOTTOM_OR_RIGHT);
		queryDataPlot.setDataset(3, pressureLDataset);
		queryDataPlot.mapDatasetToRangeAxis(3, 3);
		queryDataPlot.setRenderer(3, prsLRenderer);
	
		//Pressure Right
		XYLineAndShapeRenderer prsRRenderer = new XYLineAndShapeRenderer();
		prsRRenderer.setBaseShape(new Rectangle2D.Float(-2.0F, -2.0F, 4.0F, 4.0F));
		prsRRenderer.setBasePaint(Color.cyan);
		prsRRenderer.setUseFillPaint(true);
		prsRRenderer.setBaseFillPaint(Color.LIGHT_GRAY);
		prsRRenderer.setBaseShapesVisible(true);
		prsRRenderer.setBaseShapesFilled(true);
		prsRRenderer.setSeriesPaint(0, Color.cyan);
		CustomXYToolTipGenerator prRToolTipGenerator = new CustomXYToolTipGenerator();
		prRToolTipGenerator.addToolTipSeries(this.prRToolTipArray);
		//XYToolTipGenerator prsRToolTipGenerator = new StandardXYToolTipGenerator("{0}: ({1}, {2})", DateFormat.getDateTimeInstance(), NumberFormat.getInstance());
		prsRRenderer.setBaseToolTipGenerator(prRToolTipGenerator);
		
		queryDataPlot.setRangeAxis(4, pressureRAxis);
		queryDataPlot.setRangeAxisLocation(4, AxisLocation.BOTTOM_OR_RIGHT);
		queryDataPlot.setDataset(4, pressureRDataset);
		queryDataPlot.mapDatasetToRangeAxis(4, 4);
		queryDataPlot.setRenderer(4, prsRRenderer);
	
		//Pad Life
		XYLineAndShapeRenderer padRenderer = new XYLineAndShapeRenderer();
		padRenderer.setBaseShape(new Rectangle2D.Float(-2.0F, -2.0F, 4.0F, 4.0F));
		padRenderer.setBasePaint(Color.magenta);
		padRenderer.setUseFillPaint(true);
		padRenderer.setBaseFillPaint(Color.LIGHT_GRAY);
		padRenderer.setBaseShapesVisible(true);
		padRenderer.setBaseShapesFilled(true);
		padRenderer.setSeriesPaint(0, Color.magenta);
		CustomXYToolTipGenerator padToolTipGenerator = new CustomXYToolTipGenerator();
		padToolTipGenerator.addToolTipSeries(this.padToolTipArray);
		//XYToolTipGenerator padToolTipGenerator = new StandardXYToolTipGenerator("{0}: ({1}, {2})", DateFormat.getDateTimeInstance(), NumberFormat.getInstance());
		padRenderer.setBaseToolTipGenerator(padToolTipGenerator);
		
		queryDataPlot.setRangeAxis(5, padLifeAxis);
		queryDataPlot.setRangeAxisLocation(5, AxisLocation.BOTTOM_OR_RIGHT);
		queryDataPlot.setDataset(5, padLifeDataset);
		queryDataPlot.mapDatasetToRangeAxis(5, 5);
		queryDataPlot.setRenderer(5, padRenderer);
		
		// Add Horizontal Axis
		queryDataPlot.setDomainAxis(dateAxis);
	}

	/**
	 * Load the data from the List parameter and plot the Line Chart
	 * @param sList List of StationStatus object
	 * @param pList List of PadLife object
	 */
	public void loadData(String title, List<StationStatus> sList, List<PadeLapse> pList)
	{		
		tempDataset.removeAllSeries();
		vacuumLDataset.removeAllSeries();
		vacuumRDataset.removeAllSeries();
		pressureLDataset.removeAllSeries();
		pressureRDataset.removeAllSeries();
		padLifeDataset.removeAllSeries();
				
		tempSeries.clear();
		vacuumLSeries.clear();
		vacuumRSeries.clear();
		pressureLSeries.clear();
		pressureRSeries.clear();
		padLifeSeries.clear();
		
		tmpToolTipArray.clear();
		vcLToolTipArray.clear();
		vcRToolTipArray.clear();
		prLToolTipArray.clear();
		prRToolTipArray.clear();
		padToolTipArray.clear();
		
		queryDataPlot.setRangeAxis(0, null);
		queryDataPlot.setRangeAxis(1, null);
		queryDataPlot.setRangeAxis(2, null);
		queryDataPlot.setRangeAxis(3, null);
		queryDataPlot.setRangeAxis(4, null);
		queryDataPlot.setRangeAxis(5, null);
		
		int index=0;
		// Fill Data Set (TimeSeries) for StationStatus table
		for(StationStatus statusItem : sList)
		{
			if(temperature){
				tempSeries.addOrUpdate(new Millisecond(statusItem.getId().getDataDate()), statusItem.getTemperature());
				index = tempSeries.getIndex(new Millisecond(statusItem.getId().getDataDate()));
				tmpToolTipArray.add(index, "Temperature: "+Constants.GRAPH_DF.format(statusItem.getTemperature())+" ("+statusItem.getCurrentPadId()+" @ "+statusItem.getId().getDataDate()+")");
			}
			
			if(vacuumL){
				vacuumLSeries.addOrUpdate(new Millisecond(statusItem.getId().getDataDate()), statusItem.getVacuumLeft());
				index = vacuumLSeries.getIndex(new Millisecond(statusItem.getId().getDataDate()));
				vcLToolTipArray.add(index, "Vacuum Left: "+Constants.GRAPH_DF.format(statusItem.getVacuumLeft())+" ("+statusItem.getCurrentPadId()+" @ "+statusItem.getId().getDataDate()+")");
			}
				
			if(vacuumR){
				vacuumRSeries.addOrUpdate(new Millisecond(statusItem.getId().getDataDate()), statusItem.getVacuumRight());
				index = vacuumRSeries.getIndex(new Millisecond(statusItem.getId().getDataDate()));
				vcRToolTipArray.add(index, "Vacuum Right: "+Constants.GRAPH_DF.format(statusItem.getVacuumRight())+" ("+statusItem.getCurrentPadId()+" @ "+statusItem.getId().getDataDate()+")");
			}
			
			if(pressureL){
				pressureLSeries.addOrUpdate(new Millisecond(statusItem.getId().getDataDate()), statusItem.getPressureLeft());
				index = pressureLSeries.getIndex(new Millisecond(statusItem.getId().getDataDate()));
				prLToolTipArray.add(index, "Pressure Left: "+Constants.GRAPH_DF.format(statusItem.getPressureLeft())+" ("+statusItem.getCurrentPadId()+" @ "+statusItem.getId().getDataDate()+")");
			}
			
			if(pressureR){
				pressureRSeries.addOrUpdate(new Millisecond(statusItem.getId().getDataDate()), statusItem.getPressureRight());
				index = pressureRSeries.getIndex(new Millisecond(statusItem.getId().getDataDate()));
				prRToolTipArray.add(index, "Pressure Right: "+Constants.GRAPH_DF.format(statusItem.getPressureRight())+" ("+statusItem.getCurrentPadId()+" @ "+statusItem.getId().getDataDate()+")");
			}
		}
		
		// Create and Fill Data Set (TimeSeries) for PadLife table
		System.out.println(pList.size()+"xxxx");
		if(padlife && pList.size()!=0){				
			DatabaseManager db = new DatabaseManager();
			// Calculate elapse hour for 1st padeLapse object
			List<PadeLapse> pList2 = db.listPadElapseOfPadID(pList.get(0).getId().getPadID());
			long elapse = 0L;
			Date pDate = pList.get(0).getId().getStartTime();
			for(PadeLapse pItem2 : pList2)
			{
				if(pItem2.getId().getStartTime().equals(pDate))
					break;
				
				elapse += pItem2.getElapseTimeMillis();
			}
			padLifeSeries.addOrUpdate(new Millisecond(pDate), elapse / 3600000.0D);
			index = padLifeSeries.getIndex(new Millisecond(pDate));
			padToolTipArray.add(index, "Pad Life: "+ (elapse / 3600000.0D) +" ("+pDate+")");
			
			DecimalFormat df = new DecimalFormat("#.##");
			
			// Get elapse for the remaining padeLapse Object
			String currPadID = pList.get(0).getId().getPadID();
			for(int i=1; i<pList.size(); i++)
			{	
				PadeLapse pItem = pList.get(i);
				if(! pItem.getId().getPadID().equals(currPadID))
				{
					elapse = 0L;
					currPadID = pItem.getId().getPadID();
				}
				padLifeSeries.addOrUpdate(new Millisecond(pItem.getId().getStartTime()), elapse / 3600000.0D);
				index = padLifeSeries.getIndex(new Millisecond(pItem.getId().getStartTime()));
				padToolTipArray.add(index, "Pad Life: "+ df.format(elapse / 3600000.0D) +" ("+pItem.getId().getStartTime()+")");
				
				elapse += pItem.getElapseTimeMillis();
				
				padLifeSeries.addOrUpdate(new Millisecond(pItem.getEndTime()), elapse / 3600000.0D);
				index = padLifeSeries.getIndex(new Millisecond(pItem.getEndTime()));
				padToolTipArray.add(index, "Pad Life: "+ df.format(elapse / 3600000.0D) +" ("+pItem.getEndTime()+")");
			}
		}
		
		if(temperature)
		{
			tempDataset.addSeries(tempSeries);	
			queryDataPlot.setRangeAxis(0, temperatureAxis);
			queryDataPlot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT);
			queryDataPlot.mapDatasetToRangeAxis(0, 0);
		}	
		
		if(vacuumL)
		{
			vacuumLDataset.addSeries(vacuumLSeries);
			queryDataPlot.setRangeAxis(1, vacuumLAxis);
			queryDataPlot.setRangeAxisLocation(1, AxisLocation.TOP_OR_LEFT);
			queryDataPlot.mapDatasetToRangeAxis(1, 1);
		}
		
		if(vacuumR)
		{
			vacuumRDataset.addSeries(vacuumRSeries);
			queryDataPlot.setRangeAxis(2, vacuumRAxis);
			queryDataPlot.setRangeAxisLocation(2, AxisLocation.TOP_OR_LEFT);
			queryDataPlot.mapDatasetToRangeAxis(2, 2);
		}
		
		if(pressureL)
		{
			pressureLDataset.addSeries(pressureLSeries);
			queryDataPlot.setRangeAxis(3, pressureLAxis);
			queryDataPlot.setRangeAxisLocation(3, AxisLocation.BOTTOM_OR_RIGHT);
			queryDataPlot.mapDatasetToRangeAxis(3, 3);
		}
		
		if(pressureR)
		{
			pressureRDataset.addSeries(pressureRSeries);
			queryDataPlot.setRangeAxis(4, pressureRAxis);
			queryDataPlot.setRangeAxisLocation(4, AxisLocation.BOTTOM_OR_RIGHT);
			queryDataPlot.mapDatasetToRangeAxis(4, 4);
		}
		
		if(padlife)
		{
			padLifeDataset.addSeries(padLifeSeries);
			queryDataPlot.setRangeAxis(5, padLifeAxis);
			queryDataPlot.setRangeAxisLocation(5, AxisLocation.BOTTOM_OR_RIGHT);
			queryDataPlot.mapDatasetToRangeAxis(5, 5);
		}
		
		queryDataChart.setTitle(title);
		this.restoreAutoBounds();
	}
	
	public void drawChart(Graphics2D g2, Rectangle2D r2D)
	{
		queryDataChart.draw(g2, r2D);
	}
	
	/**
	 * Set the Temperature flag to controls whether the graph should plot
	 * temperature value
	 * @param value Temperature flag
	 */
	public void setTemperature(boolean value)
	{
		temperature = value;
	}
	
	/**
	 * Set the Vacuum Left flag to controls whether the graph should plot
	 * vacuum left value
	 * @param value Vacuum Left flag
	 */
	public void setVacuumLeft(boolean value)
	{
		vacuumL = value;
	}
	
	/**
	 * Set the Vacuum Right flag to controls whether the graph should plot
	 * vacuum right value
	 * @param value Vacuum Right flag
	 */
	public void setVacuumRight(boolean value)
	{
		vacuumR = value;
	}
	
	/**
	 * Set the Pressure Left flag to controls whether the graph should plot
	 * pressure left value
	 * @param value Pressure Left flag
	 */
	public void setPressureLeft(boolean value)
	{
		pressureL = value;
	}
	
	/**
	 * Set the Pressure Right flag to controls whether the graph should plot
	 * pressure right value
	 * @param value Pressure Right flag
	 */
	public void setPressureRight(boolean value)
	{
		pressureR = value;
	}
	
	/**
	 * Set the Pad Life flag to controls whether the graph should plot
	 * pad life value
	 * @param value Pad Life flag
	 */
	public void setPadLife(boolean value)
	{
		padlife = value;
	}
	
	/**
	 * Get Temperature flag
	 * @return Temperature flag
	 */
	public boolean getTemperature()
	{
		return temperature;
	}
		
	/**
	 * Get Vacuum Left flag
	 * @return Vacuum Left flag
	 */
	public boolean getVacuumLeft()
	{
		return vacuumL;
	}
	
	/**
	 * Get Vacuum Right flag
	 * @return Vacuum Right flag
	 */
	public boolean getVacuumRight()
	{
		return vacuumR;
	}
	
	/**
	 * Get Pressure Left flag
	 * @return Pressure Left flag
	 */
	public boolean getPressureLeft()
	{
		return pressureL;
	}
	
	/**
	 * Get Pressure Right flag
	 * @return Pressure Right flag
	 */
	public boolean getPressureRight()
	{
		return pressureR;
	}
	
	/**
	 * Get Pad Life flag
	 * @return Pad Life flag
	 */
	public boolean getPadLife()
	{
		return padlife;
	}


	public static void main(String [] args)
	{
		
		db.DatabaseManager dm = new db.DatabaseManager();
		DateFormat dtFmt = new java.text.SimpleDateFormat();
		
		List<db.entity.StationStatus> sList;
		List<db.entity.PadeLapse> sList2;
		try {
			sList = dm.listStationStatusByStationNameDate("03", dtFmt.parse("08/04/2010 9:0 AM, PDT"), dtFmt.parse("08/04/2010 1:30 PM, PDT"));
			sList2 = dm.listPadElapseByStationNameDate("03", dtFmt.parse("08/04/2010 9:0 AM, PDT"), dtFmt.parse("08/04/2010 1:30 PM, PDT"));
			QueryDataChartPanel qdcPnl = new QueryDataChartPanel();
	//		qdcPnl.setTemperature(true);
	//		qdcPnl.setPadLife(true);
	//		qdcPnl.setVacuumLeft(true);
			qdcPnl.setVacuumRight(true);
			qdcPnl.setPressureLeft(true);
	//		qdcPnl.setPressureRight(true);
			qdcPnl.loadData("Polisher Station 03",sList, sList2);
			javax.swing.JFrame window = new javax.swing.JFrame("Testing Graph");
			window.setLayout(new FlowLayout());
			window.getContentPane().add(qdcPnl);
	        window.setSize(800, 500);
	        window.setLocation(50, 50);
			window.setVisible(true);
			
		} catch (ParseException e) {
			e.printStackTrace();
		}		
	}
}

